# -*- coding: utf-8 -*-
import pymysql

print('请输入要查询的俩个作者：')
author1 = input("作者一：")
author2 = input("作者二：")

# 打开数据库连接
connection = pymysql.connect(host = '',
                            user = '',
                            password = '',
                            db = '',
                            charset = 'utf8')

# 使用 cursor() 方法创建一个游标对象 cursor
cursor = connection.cursor()

sql = "SELECT * FROM author_conn2 where name_1='%s' and name_2='%s' or name_1='%s' and name_2='%s'"%(author1,author2,author2,author1)
# 使用 execute()  方法执行 SQL 查询 
cursor.execute(sql)
result = cursor.fetchall()

print("合作次数为：",end='')
print(len(result))
print("合作过的论文有：")
for item in result:
    print(item[2])
